package com.texplose.service.impl;

import com.texplose.entity.vo.CommentVo;
import com.texplose.entity.vo.ResponseResult;
import com.texplose.entity.vo.SendCommentVo;
import com.texplose.mapper.CommentMapper;
import com.texplose.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author : lyj
 * @Timer : 2022/5/31
 * @Description :
 */
@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentMapper commentMapper;

    @Override
    public ResponseResult listComment(Integer recipeId) {
        List<CommentVo> commentVos = commentMapper.listComment(recipeId);
        return ResponseResult.okResult(commentVos);
    }

    @Override
    public ResponseResult count(Integer recipeId) {
        Integer count = commentMapper.count(recipeId);
        return ResponseResult.okResult(count);
    }

    @Override
    public ResponseResult insertComment(SendCommentVo commentVo) {
        commentMapper.insert(commentVo);
        return ResponseResult.okResult();
    }
}
